
package com.rt.schedulenew.web;

import com.rt.schedulebase.dto.*;
import com.rt.schedulebase.entity.ExamExport;
import com.rt.schedulenew.api.*;
import com.rt.schedulenew.utils.global.BusinessException;
import com.rt.schedulenew.utils.global.JsonResult;
import com.rt.schedulenew.utils.global.JsonResultUtil;
import com.rt.schedulenew.utils.util.*;
import com.rt.schedulenew.utils.global.ExcelData;
import com.rt.schedulebase.dto.BreakPromiseCountDto;
import com.rt.schedulebase.dto.ConfigDto.CustomExcel;
import com.rt.schedulebase.dto.ConfigDto.SortSet;
import com.rt.schedulenew.service.impl.CommonServiceImpl;
import com.rt.schedulenew.service.impl.ConfigServiceImpl;
import com.rt.schedulenew.utils.base.CommonUtil;
import com.rt.schedulenew.utils.base.ConstantsUtil.ConfigName;
import com.rt.schedulenew.utils.base.ConstantsUtil.TerminalType;
import com.rt.schedulebase.entity.DictDept;
import com.rt.schedulebase.entity.DictWard;

import java.util.*;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping({"/poi"})
public class PoiController {
    @Autowired
    private IExamApplyService examApplyService;
    @Autowired
    private IExamExportService examExportService;
    @Autowired
    private IExamReferService examReferService;
    @Autowired
    private IExamScheduleService examScheduleService;
    @Autowired
    private IChartsService chartsService;
    @Autowired
    private ICommonService commonService;
    @Autowired
    private ConfigServiceImpl configService;
    @Autowired
    private IDictDeptService dictDeptService;
    @Autowired
    private IDictWardService dictWardService;
    @Autowired
    private IDictExamItemService dictExamItemService;
    @Autowired
    private IDictUsersService dictUsersService;

    @RequestMapping({"/createExcel"})
    public void createExcel(ExamApplyDto dto, HttpServletResponse response) {
        String terminalType = dto.getTerminalType();
        boolean isClinic = false;
        if (StringUtils.isNotBlank(terminalType) && (TerminalType.CLINIC_IN.getType().equals(terminalType) || TerminalType.CLINIC_OUT.getType().equals(terminalType))) {
            isClinic = true;
        }
        ExcelData data = new ExcelData();
        data.setName("预约检查记录");
        JsonResult result = null;
        String customConfigName = "";
        String customExcelSortSetConfigName = "";
        if ("1".equals(dto.getPortFlag())) {
            result = examReferService.getExamReferSchedules(dto);
            customConfigName = ConfigName.YY_CUSTOMEXCEL_BY_VIRTUAL_ORDER.getKey();
            customExcelSortSetConfigName = ConfigName.YY_CUSTOMEXCEL_SORT_SET_BY_VIRTUAL_ORDER.getKey();
        } else {
            result = examApplyService.getExamSchedules(dto);
            customConfigName = ConfigName.YY_CUSTOMEXCEL.getKey();
            customExcelSortSetConfigName = ConfigName.YY_CUSTOMEXCEL_SORT_SET.getKey();
            if (isClinic) {
                customConfigName = ConfigName.YY_CUSTOMEXCEL_BY_DEPTSCHE.getKey();
                customExcelSortSetConfigName = ConfigName.YY_CUSTOMEXCEL_SORT_SET_BY_DEPTSCHE.getKey();
            }
        }
        String customExcelSortSetStr = configService.getConfigByName(customExcelSortSetConfigName);
        String wardName;
        if (StringUtils.isNotBlank(customExcelSortSetStr)) {
            SortSet customExcelSortSet = (SortSet) JsonUtil.toBean(customExcelSortSetStr, SortSet.class);
            if (customExcelSortSet != null) {
                DictUsersDto dictUsers = new DictUsersDto();
                if (isClinic) {
                    if (StringUtils.isNotBlank(dto.getUserId())) {
                        dictUsers = dictUsersService.getUserInfo(dto.getUserId());
                    } else {
                        dictUsers.setUserId(dto.getUserId());
                        dictUsers.setName(dto.getUserName());
                    }
                } else {
                    dictUsers = commonService.dictUsers(new ExamApplyDto());
                }
                String deptName = StringUtils.isNotBlank(dictUsers.getDeptName()) ? dictUsers.getDeptName() : "";
                wardName = StringUtils.isNotBlank(dictUsers.getWardName()) ? dictUsers.getWardName() : "";
                String title = "预约检查记录";
                if (StringUtils.isNotBlank(customExcelSortSet.getTitle())) {
                    title = customExcelSortSet.getTitle();
                    StringBuilder deptSb = new StringBuilder();
                    StringBuilder wardSb = new StringBuilder();
                    String deptCode = StringUtils.isNotBlank(dto.getDeptCode()) ? dto.getDeptCode() : dto.getReqDept();
                    if (StringUtils.isNotBlank(deptCode)) {
                        DictDeptDto deptDto = new DictDeptDto();
                        deptDto.setDeptCode(dto.getDeptCode());
                        List<DictDept> deptList = dictDeptService.getList(deptDto);
                        if (deptList != null && !deptList.isEmpty()) {
                            for (DictDept dictDept : deptList) {
                                deptSb.append("," + dictDept.getDeptName());
                            }
                        }
                    }
                    String wardCode = StringUtils.isNotBlank(dto.getWardCode()) ? dto.getWardCode() : dto.getReqWardCode();
                    if (StringUtils.isNotBlank(wardCode)) {
                        DictWardDto wardDto = new DictWardDto();
                        wardDto.setWardCode(dto.getReqWardCode());
                        List<DictWard> wardList = dictWardService.getList(wardDto);
                        if (wardList != null && !wardList.isEmpty()) {
                            for (DictWard dictWard : wardList) {
                                wardSb.append("," + dictWard.getWardName());
                            }
                        }
                    }
                    title = title.replace("#REQ_DEPT_NAME", StringUtils.isNotBlank(deptSb.toString()) ? deptSb.substring(1) : deptName);
                    title = title.replace("#REQ_WARD_NAME", StringUtils.isNotBlank(wardSb.toString()) ? wardSb.substring(1) : wardName);
                }
                String fontSize = customExcelSortSet.getFontSize();
                data.setTitle(title);
                data.setFontSize(fontSize);
            }
        }
        List<ExamApplyDto> eas = (List<ExamApplyDto>) result.getResult();
        if (CollectionUtils.isEmpty(eas)) {
            throw new BusinessException("暂无数据！");
        }
        //List<ExamApplyDto> eas = (List<ExamApplyDto>) result.getResult();
        List<String> titles = new ArrayList<>();
        List<String> mateNameList = new ArrayList<>();
        wardName = configService.getConfigByName(customConfigName);
        int percentage;
        if (StringUtils.isNotBlank(wardName)) {
            List<CustomExcel> customExcelList = JsonUtil.toList(wardName, CustomExcel.class);
            int[] fixedColumns = new int[customExcelList.size()];
            if (!customExcelList.isEmpty()) {
                for (int i = 0; i < customExcelList.size(); ++i) {
                    CustomExcel ce = customExcelList.get(i);
                    titles.add(ce.getColumnName());
                    mateNameList.add(ce.getMateName());
                    percentage = ce.getPercentage() != null ? ce.getPercentage() : 20;
                    fixedColumns[i] = percentage;
                }
            }
            data.setTitles(titles);
            data.setFixedColumns(fixedColumns);
        }
        Map<String, Object> map = new HashMap<>();
        List<List<Object>> rows = new ArrayList<>();
        List<String> applyNos = new ArrayList<>();
        List<ExamExport> exports = new ArrayList<>();
        percentage = 0;
        for (int length = eas.size(); percentage < length; ++percentage) {
            ExamApplyDto ea = eas.get(percentage);
            List<Object> row = new ArrayList<>();
            map.put("name", ea.getName());
            map.put("sex", ea.getSex());
            map.put("age", ea.getAge());
            map.put("phoneNumber", ea.getPhoneNumber());
            map.put("itemNameStr", ea.getItemNameStr());
            map.put("reqDate", ea.getReqDate());
            map.put("scheduleDate", ea.getScheduleDate());
            map.put("scheduleApm", ea.getScheduleApm());
            map.put("sickId", ea.getSickId());
            map.put("bedNo", ea.getBedNo());
            map.put("nurseUnit", ea.getNurseUnit());
            map.put("patientSource", ea.getPatientSource());
            map.put("clinDiag", ea.getClinDiag());
            map.put("reqDeptName", ea.getReqDeptName());
            map.put("applyNo", ea.getApplyNo());
            map.put("reqPhysician", ea.getReqPhysician());
            map.put("examClass", ea.getExamClass());
            map.put("queueName", ea.getQueueName());
            map.put("outpatientNo", ea.getOutpatientNo());
            map.put("icCard", ea.getIcCard());
            map.put("schePath", ea.getSchePath());
            map.put("location", ea.getLocation());
            map.put("clinSymp", ea.getClinSymp());
            map.put("reqWardName", ea.getReqWardName());
            map.put("inpatientNo", ea.getInpatientNo());
            map.put("priorityOrder", ea.getPriorityOrder());
            map.put("transTool", ea.getTransTool());
            map.put("accomExam", ea.getAccomExam());
            map.put("scheduleStatus", CommonUtil.status2Text(ea.getScheduleStatus()));
            map.put("realApplyNo", ea.getRealApplyNo());
            map.put("organs", ea.getOrgans());
            map.put("scheduler", ea.getScheduler());
            map.put("chargeFlag", CommonUtil.chargeFlag2Text(ea.getChargeFlag()));
            map.put("examRequireStr", ea.getExamRequireStr());
            map.put("timeEarliest", ea.getTimeEarliest());
            map.put("timeSignin", ea.getTimeSignin());
            map.put("signLocation", ea.getSignLocation());
            map.put("sequence", percentage + 1);
            for (String mateName : mateNameList) {
                row.add(map.get(mateName));
            }
            rows.add(row);
            ExamExport examExport = new ExamExport();
            examExport.setExamNo(ea.getApplyNo());
            examExport.setExportStatus("2");
            examExport.setSystemName("JCYY");
            examExport.setExportDate(DateUtil.getCurrDateStr());
            examExport.setExportTime(DateUtil.getCurrentTime());
            if (examExportService.update(examExport) == 0) {
                exports.add(examExport);
                applyNos.add(ea.getApplyNo());
            }
        }
        TreeSet<ExamExport> treeSet = new TreeSet<>(Comparator.comparing(ExamExport::getExamNo));
        exports = new ArrayList<>(treeSet);

        examExportService.saveBatch(exports);
        data.setRows(rows);
        try {
            ExcelUtils.exportExcel(response, "预约检查记录", data, false);
        } catch (Exception var24) {
            ExamExportDto examExportDto = new ExamExportDto();
            examExportDto.setExportStatus("3");
            examExportDto.setApplyNos(applyNos);
            examExportService.updateList(examExportDto);
            var24.printStackTrace();
        }
    }

    @RequestMapping({"/checkExportList"})
    public void checkExportList(ExamScheduleDto dto, HttpServletResponse response) {
        Map<String, Object> result = examScheduleService.checkRateCount(dto);
        String customConfigName = ConfigName.YY_CUSTOMEXCEL_BY_REGISTER_RATE_COUNT.getKey();
        if (result != null) {
            List<String> columns = (List<String>) result.get("column");
            List<ExamScheduleDto> datas = (List<ExamScheduleDto>) result.get("data");
            Map<String, Object> queueAvg = (Map<String, Object>) result.get("queueAvg");
            String search1 = StringUtils.isNotBlank(dto.getStartDate()) ? dto.getStartDate() + "至" + dto.getEndDate() + " " : "";
            String search2 = StringUtils.isNotBlank(dto.getExamClass()) ? "检查类别：" + dto.getExamClass() + " " : "";
            String search3 = StringUtils.isNotBlank(dto.getPerformDeptName()) ? "检查科室：" + dto.getPerformDeptName() + " " : "";
            String search4 = StringUtils.isNotBlank(dto.getQueueName()) ? "预约队列：" + dto.getQueueName() + " " : "";
            ExcelData data = new ExcelData();
            data.setSelectMemo(search1 + search2 + search3 + search4);
            data.setName("报到率统计分析");
            List<String> titles = new ArrayList<>();
            titles.add("队列");
            List<String> mateNameList = new ArrayList<>();
            mateNameList.add("queueName");
            String startDate = dto.getStartDate();
            String endDate = dto.getEndDate();
            int j = DateUtil.getIntervalDays(startDate, endDate);
            int[] fixedColumns = new int[j + 2];
            for (int i = 0; i < j + 2; ++i) { // 列表中除包含查询时间范围内的日期列外还包含 ‘队列’ 、 ‘平均’ 两列，需 +2
                String da = DateUtil.addDays2(dto.getStartDate(), i + 1);
                titles.add(da);
                mateNameList.add(da);
                fixedColumns[i] = 16;
            }
            titles.add("平均");
            mateNameList.add("queuesAvg");
            data.setTitles(titles);
            data.setFixedColumns(fixedColumns);
            List<List<Object>> rows = new ArrayList();
            Map<String, Object> map = new HashMap();
            for (int i = 0; i < columns.size(); ++i) {
                String queueName = (String) columns.get(i);
                List<Object> row = new ArrayList();
                map.put("queueName", queueName);
                Iterator var24 = datas.iterator();
                while (var24.hasNext()) {
                    ExamScheduleDto examScheduleDto = (ExamScheduleDto) var24.next();
                    List<ExamScheduleDto> queueDates = (List) examScheduleDto.getQueueDate();
                    Iterator var27 = queueDates.iterator();
                    while (var27.hasNext()) {
                        ExamScheduleDto queueDate = (ExamScheduleDto) var27.next();
                        if (queueName.equals(queueDate.getQueueName())) {
                            map.put(examScheduleDto.getScheduledDate(), queueDate.getCheckRate());
                        }
                    }
                }
                map.put("queuesAvg", queueAvg.get(queueName));
                var24 = mateNameList.iterator();
                while (var24.hasNext()) {
                    String mateName = (String) var24.next();
                    row.add(map.get(mateName));
                }
                rows.add(row);
            }
            data.setRows(rows);
            try {
                ExcelUtils.exportExcel(response, "报到率统计分析", data, false);
            } catch (Exception var29) {
                var29.printStackTrace();
                throw new BusinessException(var29.getMessage());
            }
        }
    }

    @RequestMapping({"/scheduleExportList"})
    public void scheduleExportList(ChartsDto dto, HttpServletResponse response) {
        String search1 = StringUtils.isNotBlank(dto.getStartDate()) ? dto.getStartDate() + "至" + dto.getEndDate() + " " : "";
        String search2 = StringUtils.isNotBlank(dto.getExamClass()) ? "检查类别：" + dto.getExamClass() + " " : "";
        String search3 = StringUtils.isNotBlank(dto.getPerformDeptName()) ? "检查科室：" + dto.getPerformDeptName() + " " : "";
        String search4 = StringUtils.isNotBlank(dto.getQueueName()) ? "预约队列：" + dto.getQueueName() + " " : "";
        ExcelData data = new ExcelData();
        data.setSelectMemo(search1 + search2 + search3 + search4);
        data.setName("占号率统计分析");
        Map<String, Object> result = chartsService.getScheduleOrgansCount(dto);
        if (result != null) {
            String customConfigName = ConfigName.YY_CUSTOMEXCEL_BY_OCCUPY_RATE_COUNT.getKey();
            List<String> columns = (List) result.get("column");
            List<ExamApplyDto> datas = (List) result.get("data");
            Map<String, Object> dateAvg = (Map) result.get("dateAvg");
            List<String> titles = new ArrayList();
            titles.add("队列");
            List<String> mateNameList = new ArrayList();
            mateNameList.add("queueName");
            int[] fixedColumns = new int[columns.size() + 2];
            for (int i = 0; i < columns.size(); ++i) {
                String da = (String) columns.get(i);
                titles.add(da);
                mateNameList.add(da);
                fixedColumns[i] = 16;
            }
            for (int i = 0; i < fixedColumns.length; i++) {
                fixedColumns[i] = 16;
            }
            titles.add("平均");
            mateNameList.add("queuesAvg");
            data.setTitles(titles);
            data.setFixedColumns(fixedColumns);
            List<List<Object>> rows = new ArrayList();
            Map<String, Object> map = new HashMap();
            List<Object> lastRow = new ArrayList();
            Iterator var19 = datas.iterator();
            while (var19.hasNext()) {
                ExamApplyDto charts = (ExamApplyDto) var19.next();
                List<Object> row = new ArrayList();
                map.put("queueName", charts.getQueueName());
                List<ExamApplyDto> numRates = (List) charts.getNumRate();
                Iterator var23 = numRates.iterator();
                while (var23.hasNext()) {
                    ExamApplyDto chart = (ExamApplyDto) var23.next();
                    map.put(chart.getScheduledDate(), chart.getOrgans());
                }
                map.put("queuesAvg", charts.getQueueAvg());
                var23 = mateNameList.iterator();
                while (var23.hasNext()) {
                    String mateName = (String) var23.next();
                    row.add(map.get(mateName));
                }
                rows.add(row);
            }
            dateAvg.put("队列", "平均");
            dateAvg.put("平均", "--");
            var19 = titles.iterator();
            while (var19.hasNext()) {
                String scheDate = (String) var19.next();
                lastRow.add(dateAvg.get(scheDate));
            }
            rows.add(lastRow);
            data.setRows(rows);
            try {
                ExcelUtils.exportExcel(response, "占号率统计分析", data, false);
            } catch (Exception var25) {
                var25.printStackTrace();
            }
        }
    }

    @RequestMapping({"/hosCheckExportList"})
    public void hosCheckExportList(ChartsDto dto, HttpServletResponse response) {
        Map<String, Object> result = chartsService.getSignInCount(dto);
        if (result != null) {
            String customConfigName = ConfigName.YY_CUSTOMEXCEL_BY_HOSPITAL_RATE_COUNT.getKey();
            List<ExamApplyDto> datas = (List) result.get("data");
            String search1 = StringUtils.isNotBlank(dto.getStartDate()) ? dto.getStartDate() + "至" + dto.getEndDate() + " " : "";
            String search2 = StringUtils.isNotBlank(dto.getExamClass()) ? "检查类别：" + dto.getExamClass() + " " : "";
            String search3 = StringUtils.isNotBlank(dto.getPerformDeptName()) ? "检查科室：" + dto.getPerformDeptName() + " " : "";
            String search4 = StringUtils.isNotBlank(dto.getQueueName()) ? "预约队列：" + dto.getQueueName() + " " : "";
            ExcelData data = new ExcelData();
            data.setSelectMemo(search1 + search2 + search3 + search4);
            data.setName("新住院报到率统计分析");
            List<String> titles = new ArrayList<>();
            titles.add("队列");
            List<String> mateNameList = new ArrayList<>();
            mateNameList.add("queueName");
            String startDate = dto.getStartDate();
            String endDate = dto.getEndDate();
            int j = DateUtil.getIntervalDays(startDate, endDate);
            int[] fixedColumns = new int[j + 2];
            for (int i = 0; i < j; ++i) {
                String da = DateUtil.addDays2(dto.getStartDate(), i + 1);
                titles.add(da);
                mateNameList.add(da);
                fixedColumns[i] = 16;
            }
            titles.add("平均");
            mateNameList.add("queuesAvg");
            data.setTitles(titles);
            data.setFixedColumns(fixedColumns);
            List<List<Object>> rows = new ArrayList();
            Map<String, Object> map = new HashMap();
            Iterator var19 = datas.iterator();
            while (var19.hasNext()) {
                ExamApplyDto charts = (ExamApplyDto) var19.next();
                List<Object> row = new ArrayList();
                String queueName = charts.getQueueName();
                map.put("queueName", queueName);
                List<ExamApplyDto> numRates = (List) charts.getNumRate();
                Iterator var24 = numRates.iterator();
                while (var24.hasNext()) {
                    ExamApplyDto chart = (ExamApplyDto) var24.next();
                    if (queueName.equals(chart.getQueueName())) {
                        map.put(chart.getScheduledDate(), chart.getPercent());
                    }
                }
                map.put("queuesAvg", charts.getQueueAvg());
                var24 = mateNameList.iterator();
                while (var24.hasNext()) {
                    String mateName = (String) var24.next();
                    row.add(map.get(mateName));
                }
                rows.add(row);
            }
            data.setRows(rows);
            try {
                ExcelUtils.exportExcel(response, "新住院报到率统计分析", data, false);
            } catch (Exception var26) {
                var26.printStackTrace();
            }
        }
    }

    @PostMapping({"/findPrintData"})
    public JsonResult findPrintData(@RequestBody ExamApplyDto dto, HttpServletResponse response) {
        String terminalType = dto.getTerminalType();
        String printListConfigName = ConfigName.YY_PRINT_LIST.getKey();
        String printListSortSetConfigName = ConfigName.YY_PRINT_LIST_SORT_SET.getKey();
        String printListMsg = "医技端";
        DictUsersDto dictUsers = new DictUsersDto();
        if (StringUtils.isNotBlank(terminalType)
                && (TerminalType.CLINIC_IN.getType().equals(terminalType)
                || TerminalType.CLINIC_OUT.getType().equals(terminalType))) {
            printListConfigName = ConfigName.YY_PRINT_LIST_BY_DEPTSCHE.getKey();
            printListSortSetConfigName = ConfigName.YY_PRINT_LIST_SORT_SET_BY_DEPTSCHE.getKey();
            if (StringUtils.isNotBlank(dto.getUserId())) {
                dictUsers = dictUsersService.getUserInfo(dto.getUserId());
            } else {
                dictUsers.setUserId(dto.getUserId());
                dictUsers.setName(dto.getUserName());
            }
            printListMsg = "临床端";
        } else {
            dictUsers = commonService.dictUsers(new ExamApplyDto());
        }
        String printListStr = configService.getConfigByName(printListConfigName);
        if (StringUtils.isNotBlank(printListStr)) {
            List<CustomExcel> printList = JsonUtil.toList(printListStr, CustomExcel.class);
            if (printList != null && !printList.isEmpty()) {
                String printListSortSetStr = configService.getConfigByName(printListSortSetConfigName);
                String fontSize = "16";
                String title = "";
                String printTime = DateUtil.formatCurrentTime(DateUtil.TYPE_DATETIME);
                String intOrient = "1";
                String printer = StringUtils.isNotBlank(dictUsers.getName()) ? dictUsers.getName() : (StringUtils.isNotBlank(dictUsers.getUsername()) ? dictUsers.getUsername() : dto.getUserName());
                String deptName = StringUtils.isNotBlank(dictUsers.getDeptName()) ? dictUsers.getDeptName() : "";
                String wardName = StringUtils.isNotBlank(dictUsers.getWardName()) ? dictUsers.getWardName() : "";
                if (StringUtils.isNotBlank(printListSortSetStr)) {
                    SortSet printListSortSet = JsonUtil.toBean(printListSortSetStr, SortSet.class);
                    if (printListSortSet != null) {
                        if (StringUtils.isNotBlank(printListSortSet.getFontSize())) {
                            fontSize = printListSortSet.getFontSize();
                        }
                        if (StringUtils.isNotBlank(printListSortSet.getTitle())) {
                            title = printListSortSet.getTitle();
                            StringBuilder deptSb = new StringBuilder();
                            StringBuilder wardSb = new StringBuilder();
                            String deptCode = StringUtils.isNotBlank(dto.getDeptCode()) ? dto.getDeptCode() : dto.getReqDept();
                            if (StringUtils.isNotBlank(deptCode)) {
                                DictDeptDto deptDto = new DictDeptDto();
                                deptDto.setDeptCode(deptCode);
                                List<DictDept> deptList = dictDeptService.getList(deptDto);
                                if (CollectionUtils.isNotEmpty(deptList)) {
                                    deptList.forEach(dictDept->deptSb.append("," + dictDept.getDeptName()));
                                }
                            }
                            String wardCode = StringUtils.isNotBlank(dto.getWardCode()) ? dto.getWardCode() : dto.getReqWardCode();
                            if (StringUtils.isNotBlank(wardCode)) {
                                DictWardDto wardDto = new DictWardDto();
                                wardDto.setWardCode(wardCode);
                                List<DictWard> wardList = dictWardService.getList(wardDto);
                                if (wardList != null && !wardList.isEmpty()) {
                                    Iterator var31 = wardList.iterator();
                                    while (var31.hasNext()) {
                                        DictWard dictWard = (DictWard) var31.next();
                                        wardSb.append("," + dictWard.getWardName());
                                    }
                                }
                            }
                            title = title.replace("#REQ_DEPT_NAME", StringUtils.isNotBlank(deptSb.toString()) ? deptSb.substring(1) : deptName);
                            title = title.replace("#REQ_WARD_NAME", StringUtils.isNotBlank(wardSb.toString()) ? wardSb.substring(1) : wardName);
                        }
                        if (StringUtils.isNotBlank(printListSortSet.getIntOrient())) {
                            intOrient = printListSortSet.getIntOrient();
                        }
                    }
                }
                Map<String, Object> map = new HashMap();
                map.put("printList", printList);
                map.put("fontSize", fontSize);
                map.put("title", title);
                map.put("printTime", printTime);
                map.put("printer", printer);
                map.put("intOrient", intOrient);
                return JsonResultUtil.success("成功", map);
            }
        }
        return JsonResultUtil.failure("请设置【" + printListMsg + "】打印清单规格信息！");
    }

    @RequestMapping({"/breakPromiseExportList"})
    public void BreakPromiseExportList(BreakPromiseCountDto dto, HttpServletResponse response) {
        List<Map<String, Object>> list = chartsService.getReqDeptBreakPromiseCount(dto);
        if (list != null) {
            String search1 = "";
            if ("YEAR".equals(dto.getCountType())) {
                if (StringUtils.isNotBlank(dto.getPerformStartDate())) {
                    search1 = dto.getPerformStartDate().substring(0, 4) + " ";
                }
            } else if ("MONTH".equals(dto.getCountType())) {
                if (StringUtils.isNotBlank(dto.getPerformStartDate())) {
                    search1 = dto.getPerformStartDate().substring(0, 7) + " ";
                }
            } else if (StringUtils.isNotBlank(dto.getPerformStartDate())) {
                search1 = StringUtils.isNotBlank(dto.getPerformStartDate()) ? dto.getPerformStartDate() + "至" + dto.getPerformEndDate() + " " : "";
            }
            String search4 = StringUtils.isNotBlank(dto.getExamClass()) ? "检查类别：" + dto.getExamClass() + " " : "";
            String search2 = StringUtils.isNotBlank(dto.getReqHospitalName()) ? "申请院区：" + dto.getReqHospitalName() + " " : "";
            String search3 = StringUtils.isNotBlank(dto.getReqDeptName()) ? "申请科室：" + dto.getReqDeptName() + " " : "";
            ExcelData data = new ExcelData();
            data.setSelectMemo(search1 + search2 + search3 + search4);
            data.setName("爽约率统计报表");
            String customConfigName = ConfigName.YY_CUSTOMEXCEL_BY_BREAK_PROMISE_COUNT.getKey();
            List<String> titals = new ArrayList();
            Collections.addAll(titals, new String[]{"年份", "申请科室", "门诊预约量", "门诊爽约量", "门诊爽约率", "住院预约量", "住院爽约量", "住院爽约率", "预约量", "爽约量", "爽约率"});
            if ("MONTH".equals(dto.getCountType())) {
                titals.set(0, "月份");
            } else if ("DATE".equals(dto.getCountType())) {
                titals.set(0, "日期");
            }
            List<String> mateNameList = new ArrayList();
            Collections.addAll(mateNameList, new String[]{"year", "reqDeptName", "outPatientAppointmentNum", "outPatientBreakPromiseNum", "outPatientbreakPromiseRate", "hospitalAppointmentNum", "hospitalBreakPromiseNum", "hospitalbreakPromiseRate", "appointmentTotal", "breakPromiseTotal", "breakPromiseRate"});
            if ("MONTH".equals(dto.getCountType())) {
                mateNameList.set(0, "month");
            } else if ("DATE".equals(dto.getCountType())) {
                mateNameList.set(0, "scheduledDay");
            }
            int[] fixedColumns = new int[titals.size()];
            for (int i = 0; i < titals.size(); ++i) {
                fixedColumns[i] = 16;
            }
            data.setTitles(titals);
            data.setFixedColumns(fixedColumns);
            List<List<Object>> rows = new ArrayList();
            Iterator var14 = list.iterator();
            while (var14.hasNext()) {
                Map<String, Object> map = (Map) var14.next();
                List<Object> row = new ArrayList();
                Iterator var17 = mateNameList.iterator();
                while (var17.hasNext()) {
                    String s = (String) var17.next();
                    row.add(map.get(s));
                }
                rows.add(row);
            }
            data.setRows(rows);
            try {
                ExcelUtils.exportExcel(response, "爽约率统计报表", data, false);
            } catch (Exception var19) {
                var19.printStackTrace();
            }
        }
    }

    @RequestMapping({"/wordloadExportList"})
    public void WordloadExportList(ChartsDto dto, HttpServletResponse response) {
        List<ChartsDto> list = chartsService.scheduleWordloadCount(dto);
        if (list != null) {
            String customConfigName = ConfigName.YY_CUSTOMEXCEL_BY_WORK_COUNT.getKey();
            String search2 = StringUtils.isNotBlank(dto.getExamClass()) ? "检查类别：" + dto.getExamClass() + " " : "";
            String search1 = "";
            String search3 = "";
            String search4 = "";
            if ("YEAR".equals(dto.getCountType())) {
                if (StringUtils.isNotBlank(dto.getStartYear())) {
                    search1 = dto.getStartYear() + "至" + dto.getEndYear() + " ";
                }
            } else if ("MONTH".equals(dto.getCountType())) {
                if (StringUtils.isNotBlank(dto.getStartMonth())) {
                    search1 = dto.getStartMonth() + "至" + dto.getEndMonth() + " ";
                }
            } else if ("DATE".equals(dto.getCountType()) && StringUtils.isNotBlank(dto.getStartDate())) {
                search1 = dto.getStartDate() + "至" + dto.getEndDate() + " ";
            }
            ExcelData data = new ExcelData();
            data.setName("工作量统计报表");
            List<String> tital = new ArrayList();
            Collections.addAll(tital, new String[]{"申请院区", "预约", "修改", "取消", "合计"});
            List<String> mateNameList = new ArrayList();
            Collections.addAll(mateNameList, new String[]{"reqHospitalName", "scheduleCount", "updateCount", "cancelCount", "sum"});
            if ("2".equals(dto.getChooseWorkLoadType())) {
                tital.set(0, "申请科室");
                mateNameList.set(0, "reqDeptName");
            } else if ("3".equals(dto.getChooseWorkLoadType())) {
                tital.set(0, "检查类别");
                mateNameList.set(0, "examClass");
            } else if ("4".equals(dto.getChooseWorkLoadType())) {
                tital.set(0, "预约科室");
                mateNameList.set(0, "performDeptName");
            } else if ("5".equals(dto.getChooseWorkLoadType())) {
                tital.set(0, "预约队列");
                mateNameList.set(0, "queueName");
            } else if ("6".equals(dto.getChooseWorkLoadType())) {
                tital.set(0, "操作人");
                mateNameList.set(0, "userName");
                search3 = StringUtils.isNotBlank(dto.getDeptName()) ? "操作人科室：" + dto.getDeptName() + " " : "";
                search4 = StringUtils.isNotBlank(dto.getPerformDeptName()) ? "执行科室：" + dto.getPerformDeptName() + " " : "";
            }
            data.setSelectMemo(search1 + search2 + search3 + search4);
            int[] fixedColumns = new int[tital.size()];
            for (int i = 0; i < tital.size(); ++i) {
                fixedColumns[i] = 16;
            }
            data.setTitles(tital);
            data.setFixedColumns(fixedColumns);
            List<List<Object>> rows = new ArrayList();
            String key = (String) mateNameList.get(0);
            Iterator var15 = list.iterator();
            while (var15.hasNext()) {
                ChartsDto chartsDto = (ChartsDto) var15.next();
                Map<String, Object> map = new HashMap();
                List<Object> row = new ArrayList();
                if (chartsDto.getScheduleSum() == null && chartsDto.getCancelSum() == null && chartsDto.getUpdateSum() == null) {
                    map.put("scheduleCount", chartsDto.getScheduleCount());
                    map.put("updateCount", chartsDto.getUpdateCount());
                    map.put("cancelCount", chartsDto.getCancelCount());
                    if ("1".equals(chartsDto.getChooseWorkLoadType())) {
                        map.put(key, chartsDto.getReqHospitalName());
                    } else if ("2".equals(dto.getChooseWorkLoadType())) {
                        map.put(key, chartsDto.getReqDeptName());
                    } else if ("3".equals(dto.getChooseWorkLoadType())) {
                        map.put(key, chartsDto.getExamClass());
                    } else if ("4".equals(dto.getChooseWorkLoadType())) {
                        map.put(key, chartsDto.getPerformDeptName());
                    } else if ("5".equals(dto.getChooseWorkLoadType())) {
                        map.put(key, chartsDto.getQueueName());
                    } else if ("6".equals(dto.getChooseWorkLoadType())) {
                        map.put(key, chartsDto.getUserName());
                    }
                } else {
                    map.put("scheduleCount", chartsDto.getScheduleSum());
                    map.put("cancelCount", chartsDto.getCancelSum());
                    map.put("updateCount", chartsDto.getUpdateSum());
                    map.put(key, "合计");
                }
                map.put("sum", chartsDto.getSum());
                Iterator var19 = mateNameList.iterator();
                while (var19.hasNext()) {
                    String s = (String) var19.next();
                    row.add(map.get(s));
                }
                rows.add(row);
            }
            data.setRows(rows);
            try {
                ExcelUtils.exportExcel(response, "工作量统计报表", data, false);
            } catch (Exception var21) {
                var21.printStackTrace();
            }
        }
    }

    @RequestMapping({"/scheduleCountExportList"})
    public void scheduleCountExportList(ChartsDto dto, HttpServletResponse response) {
        String search2 = StringUtils.isNotBlank(dto.getExamClass()) ? "检查类别：" + dto.getExamClass() + " " : "";
        String search1 = "";
        if ("YEAR".equals(dto.getCountType())) {
            if (StringUtils.isNotBlank(dto.getStartYear())) {
                search1 = dto.getStartYear() + "至" + dto.getEndYear() + " ";
            }
        } else if ("MONTH".equals(dto.getCountType())) {
            if (StringUtils.isNotBlank(dto.getStartMonth())) {
                search1 = dto.getStartMonth() + "至" + dto.getEndMonth() + " ";
            }
        } else if ("DATE".equals(dto.getCountType()) && StringUtils.isNotBlank(dto.getStartDate())) {
            search1 = dto.getStartDate() + "至" + dto.getEndDate() + " ";
        }
        ExcelData data = new ExcelData();
        data.setSelectMemo(search1 + search2);
        Map<String, Object> result = new HashMap();
        if ("1".equals(dto.getChooseScheduleType())) {
            result = chartsService.getReqHospitalCount(dto);
            data.setName("申请院区预约量统计报表");
        } else if ("2".equals(dto.getChooseScheduleType())) {
            result = chartsService.getReqDeptCount(dto);
            data.setName("申请科室预约量统计报表");
        } else if ("3".equals(dto.getChooseScheduleType())) {
            result = chartsService.getPerformDeptCount(dto);
            data.setName("预约科室预约量统计报表");
        } else if ("4".equals(dto.getChooseScheduleType())) {
            result = chartsService.getExamQueueCount(dto);
            data.setName("预约队列预约量统计报表");
        } else if ("5".equals(dto.getChooseScheduleType())) {
            result = chartsService.getScheduleTerminalCount(dto);
            data.setName("预约终端预约量统计报表");
        } else if ("6".equals(dto.getChooseScheduleType())) {
            result = chartsService.getReqPhysicianCount(dto);
            data.setName("申请医生预约量统计报表");
        }
        if (result != null) {
            String customConfigName = ConfigName.YY_CUSTOMEXCEL_BY_SCHEDULE_COUNT.getKey();
            List<String> tital = new ArrayList();
            List<String> mateNameList = new ArrayList();
            List<Map<String, Object>> column = (List) ((Map) result).get("column");
            Iterator var11 = column.iterator();
            while (var11.hasNext()) {
                Map<String, Object> map = (Map) var11.next();
                mateNameList.add((String) map.get("prop"));
                tital.add((String) map.get("label"));
            }
            data.setTitles(tital);
            int[] fixedColumns = new int[tital.size()];
            for (int i = 0; i < tital.size(); ++i) {
                fixedColumns[i] = 16;
            }
            data.setFixedColumns(fixedColumns);
            List<Map<String, Object>> list = (List) ((Map) result).get("data");
            List<List<Object>> rows = new ArrayList();
            Iterator var14 = list.iterator();
            while (var14.hasNext()) {
                Map<String, Object> map = (Map) var14.next();
                List<Object> row = new ArrayList();
                Iterator var17 = mateNameList.iterator();
                while (var17.hasNext()) {
                    String s = (String) var17.next();
                    row.add(map.get(s));
                }
                rows.add(row);
            }
            data.setRows(rows);
            try {
                ExcelUtils.exportExcel(response, data.getName(), data, false);
            } catch (Exception var19) {
                var19.printStackTrace();
            }
        }
    }

    @RequestMapping({"/deptUserExportList"})
    public void deptUserExportList(ChartsDto dto, HttpServletResponse response) {
        Map<String, Object> result = chartsService.getUserScheduleCount(dto);
        if (result != null) {
            String customConfigName = ConfigName.YY_CUSTOMEXCEL_BY_DEPT_USER_COUNT.getKey();
            ExcelData data = new ExcelData();
            data.setName("科室操作人员预约量统计报表");
            String search1 = "";
            if ("YEAR".equals(dto.getCountType())) {
                if (StringUtils.isNotBlank(dto.getStartYear())) {
                    search1 = dto.getStartYear() + "至" + dto.getEndYear() + " ";
                }
            } else if ("MONTH".equals(dto.getCountType())) {
                if (StringUtils.isNotBlank(dto.getStartMonth())) {
                    search1 = dto.getStartMonth() + "至" + dto.getEndMonth() + " ";
                }
            } else if ("DATE".equals(dto.getCountType()) && StringUtils.isNotBlank(dto.getStartDate())) {
                search1 = dto.getStartDate() + "至" + dto.getEndDate() + " ";
            }
            String search2 = StringUtils.isNotBlank(dto.getDeptName()) ? "操作人科室：" + dto.getDeptName() + " " : "";
            data.setSelectMemo(search1 + search2);
            List<String> tital = (List) result.get("column");
            Map<String, List<ChartsDto>> lists = (Map) result.get("dataMap");
            Map<String, Object> deptSum = (Map) result.get("deptSum");
            data.setTitles(tital);
            List<String> mateNameList = tital;
            int[] fixedColumns = new int[tital.size()];
            for (int i = 0; i < tital.size(); ++i) {
                fixedColumns[i] = 16;
            }
            data.setFixedColumns(fixedColumns);
            List<List<Object>> rows = new ArrayList();
            Map<String, Object> map = new HashMap();
            List<Object> lastRow = new ArrayList();
            Iterator var16 = lists.keySet().iterator();
            String s;
            while (var16.hasNext()) {
                s = (String) var16.next();
                List<Object> row = new ArrayList();
                map.put("操作人", s);
                Iterator var19 = ((List) lists.get(s)).iterator();
                while (var19.hasNext()) {
                    ChartsDto chartsDto = (ChartsDto) var19.next();
                    map.put(chartsDto.getPerformDeptName(), chartsDto.getCount());
                }
                var19 = mateNameList.iterator();
                while (var19.hasNext()) {
                    String ss = (String) var19.next();
                    row.add(map.get(ss));
                }
                rows.add(row);
            }
            deptSum.put("操作人", "合计");
            var16 = mateNameList.iterator();
            while (var16.hasNext()) {
                s = (String) var16.next();
                lastRow.add(deptSum.get(s));
            }
            rows.add(lastRow);
            data.setRows(rows);
            try {
                ExcelUtils.exportExcel(response, data.getName(), data, false);
            } catch (Exception var21) {
                var21.printStackTrace();
            }
        }
    }

    @RequestMapping({"/terminalTypeExportList"})
    public void TerminalTypeExportList(ChartsDto dto, HttpServletResponse response) {
        Map result;
        if ("1".equals(dto.getChooseScheduleType())) {
            result = chartsService.getPerformDeptTerminalCount(dto);
        } else {
            result = chartsService.getTerminalTypeCount(dto);
        }
        if (result != null) {
            ExcelData data = new ExcelData();
            data.setName("预约方式预约量统计报表");
            String customConfigName = ConfigName.YY_CUSTOMEXCEL_BY_TERMINAL_TYPE_COUNT.getKey();
            String search1 = "";
            if ("YEAR".equals(dto.getCountType())) {
                if (StringUtils.isNotBlank(dto.getStartYear())) {
                    search1 = dto.getStartYear() + "至" + dto.getEndYear() + " ";
                }
            } else if ("MONTH".equals(dto.getCountType())) {
                if (StringUtils.isNotBlank(dto.getStartMonth())) {
                    search1 = dto.getStartMonth() + "至" + dto.getEndMonth() + " ";
                }
            } else if ("DATE".equals(dto.getCountType()) && StringUtils.isNotBlank(dto.getStartDate())) {
                search1 = dto.getStartDate() + "至" + dto.getEndDate() + " ";
            }
            String search2 = StringUtils.isNotBlank(dto.getExamClass()) ? "检查类别：" + dto.getExamClass() + " " : "";
            String search3 = StringUtils.isNotBlank(dto.getPerformDeptName()) ? "执行科室：" + dto.getPerformDeptName() + " " : "";
            data.setSelectMemo(search1 + search2 + search3);
            List<String> tital = new ArrayList();
            List<String> mateNameList = new ArrayList();
            if ("1".equals(dto.getChooseScheduleType())) {
                tital = (List) result.get("column");
            } else {
                List<Map<String, Object>> column = (List) result.get("column");
                Iterator var12 = column.iterator();
                while (var12.hasNext()) {
                    Map<String, Object> map = (Map) var12.next();
                    mateNameList.add((String) map.get("prop"));
                    ((List) tital).add((String) map.get("label"));
                }
            }
            data.setTitles((List) tital);
            int[] fixedColumns = new int[((List) tital).size()];
            for (int i = 0; i < ((List) tital).size(); ++i) {
                fixedColumns[i] = 16;
            }
            data.setFixedColumns(fixedColumns);
            List<Map<String, Object>> lists = (List) result.get("data");
            List<List<Object>> rows = new ArrayList();
            Iterator var14 = lists.iterator();
            while (var14.hasNext()) {
                Map<String, Object> map = (Map) var14.next();
                List<Object> row = new ArrayList();
                Iterator var17 = mateNameList.iterator();
                while (var17.hasNext()) {
                    String s = (String) var17.next();
                    row.add(map.get(s));
                }
                rows.add(row);
            }
            data.setRows(rows);
            try {
                ExcelUtils.exportExcel(response, data.getName(), data, true);
            } catch (Exception var19) {
                var19.printStackTrace();
            }
        }
    }

    @RequestMapping({"/scheduleRecordExcel"})
    public void ScheduleRecordExcel(ChartsDto dto, HttpServletResponse response) {
        ExcelData data = new ExcelData();
        data.setName("预约记录统计报表");
        List<Map<String, Object>> eas = chartsService.getScheduleCount(dto);
        List<String> titles = new ArrayList();
        List<String> mateNameList = new ArrayList();
        String customExcelStr = "[{\"columnName\":\"病人姓名\",\"mateName\":\"name\",\"percentage\":20},{\"columnName\":\"性别\",\"mateName\":\"sex\",\"percentage\":12},{\"columnName\":\"年龄\",\"mateName\":\"age\",\"percentage\":20},{\"columnName\":\"门诊号\",\"mateName\":\"outpatientNo\",\"percentage\":20},{\"columnName\":\"住院号\",\"mateName\":\"inpatientNo\",\"percentage\":20},{\"columnName\":\"检查类别\",\"mateName\":\"examClass\",\"percentage\":20},{\"columnName\":\"检查科室\",\"mateName\":\"performDeptName\",\"percentage\":20},{\"columnName\":\"检查项目\",\"mateName\":\"itemName\",\"percentage\":20},{\"columnName\":\"病人来源\",\"mateName\":\"patientSource\",\"percentage\":20},{\"columnName\":\"预约渠道\",\"mateName\":\"schePath\",\"percentage\":20},{\"columnName\":\"申请医院\",\"mateName\":\"reqHospital\",\"percentage\":20},{\"columnName\":\"申请科室\",\"mateName\":\"reqDeptName\",\"percentage\":20},{\"columnName\":\"申请医生\",\"mateName\":\"reqPhysician\",\"percentage\":20},{\"columnName\":\"申请日期\",\"mateName\":\"reqDateTime\",\"percentage\":20},{\"columnName\":\"预约日期\",\"mateName\":\"scheduleDateApm\",\"percentage\":16},{\"columnName\":\"预约操作日期\",\"mateName\":\"scheduleActDateTime\",\"percentage\":20},{\"columnName\":\"报到时间\",\"mateName\":\"signDateTime\",\"percentage\":20},{\"columnName\":\"申请生效时间\",\"mateName\":\"scheduleActMinute\",\"percentage\":20},{\"columnName\":\"预约操作时间\",\"mateName\":\"signActMinute\",\"percentage\":20},{\"columnName\":\"预约日期时间\",\"mateName\":\"signMinute\",\"percentage\":20},{\"columnName\":\"是否提前报到\",\"mateName\":\"isSignBefore\",\"percentage\":12}]";
        if (StringUtils.isNotBlank(customExcelStr)) {
            List<CustomExcel> customExcelList = JsonUtil.toList(customExcelStr, CustomExcel.class);
            int[] fixedColumns = new int[customExcelList.size()];
            if (customExcelList != null && !customExcelList.isEmpty()) {
                for (int i = 0; i < customExcelList.size(); ++i) {
                    CustomExcel ce = (CustomExcel) customExcelList.get(i);
                    titles.add(ce.getColumnName());
                    mateNameList.add(ce.getMateName());
                    int percentage = ce.getPercentage() != null ? ce.getPercentage() : 20;
                    fixedColumns[i] = percentage;
                }
            }
            data.setTitles(titles);
            data.setFixedColumns(fixedColumns);
        }
        Map<String, Object> map = new HashMap();
        List<List<Object>> rows = new ArrayList();
        List<ExamExport> exports = new ArrayList();
        Iterator var20 = eas.iterator();
        while (var20.hasNext()) {
            Map<String, Object> ea = (Map) var20.next();
            List<Object> row = new ArrayList();
            map.put("name", ea.get("name"));
            map.put("sex", ea.get("sex"));
            map.put("age", ea.get("age"));
            map.put("outpatientNo", ea.get("outpatientNo"));
            map.put("inpatientNo", ea.get("inpatientNo"));
            map.put("examClass", ea.get("examClass"));
            map.put("performDeptName", ea.get("performDeptName"));
            map.put("itemName", ea.get("itemName"));
            map.put("patientSource", ea.get("patientSource"));
            map.put("schePath", CommonUtil.convertTerminalType("" + ea.get("schePath")));
            map.put("reqHospital", ea.get("reqHospital"));
            map.put("reqDeptName", ea.get("reqDeptName"));
            map.put("reqPhysician", ea.get("reqPhysician"));
            map.put("reqDateTime", ea.get("reqDate") + " " + ea.get("reqTime"));
            map.put("scheduleDateApm", ea.get("scheduledDate") + " " + ea.get("scheduledTime"));
            map.put("scheduleActDateTime", ea.get("scheduleActDate") + " " + ea.get("scheduleActTime"));
            map.put("signDateTime", ea.get("signDate") != null ? ea.get("signDate") : (" " + ea.get("signTime") != null ? ea.get("signTime") : ""));
            map.put("scheduleActMinute", ea.get("scheduleActMinute") + "分钟");
            map.put("signActMinute", ea.get("signActMinute") + "分钟");
            map.put("signMinute", ea.get("signMinute") + "分钟");
            map.put("isSignBefore", ea.get("isSignBefore") == "1" ? "是" : "否");
            Iterator var14 = mateNameList.iterator();
            while (var14.hasNext()) {
                String mateName = (String) var14.next();
                row.add(map.get(mateName));
            }
            rows.add(row);
        }
        examExportService.saveBatch(exports);
        data.setRows(rows);
        try {
            ExcelUtils.exportExcel(response, "预约记录统计报表", data, false);
        } catch (Exception var16) {
            var16.printStackTrace();
        }
    }

    @RequestMapping({"/dictItem/importExcel"})
    public JsonResult importItemExcel(@RequestParam MultipartFile file) {
        // 行 列
        List<List<String>> datas = ExcelPoiImportUtils.importFromExcel(ExcelPoiImportUtils.transferToFile(file));
        List<DictExamItemDto> items = new ArrayList();
        Iterator var4 = datas.iterator();
        while (var4.hasNext()) {
            List<String> data = (List) var4.next();
            DictExamItemDto item = new DictExamItemDto();
            item.setItemName(data.get(0));
            item.setItemCode(data.get(1));
            item.setOrgans(Double.valueOf(StringUtils.isBlank(data.get(2)) ? "1" : data.get(2)));
            item.setExamClass(data.get(3));
            item.setExamSubClass(data.get(4));
            List<String> flages = new ArrayList();
            if ("1".equals(data.get(5))) {
                flages.add("1");
            }
            if ("1".equals(data.get(6))) {
                flages.add("2");
            }
            if ("1".equals(data.get(7))) {
                flages.add("3");
            }
            if ("1".equals(data.get(8))) {
                flages.add("4");
            }
            if ("1".equals(data.get(9))) {
                flages.add("5");
            }
            if ("1".equals(data.get(10))) {
                flages.add("0,8,9,10,11");
            } else {
                if (StringUtils.isBlank(data.get(16)) || "0".equals(data.get(12))) {
                    flages.add("8");
                }
                if (!StringUtils.isBlank(data.get(13)) && !"0".equals(data.get(13)) || !StringUtils.isBlank((CharSequence) data.get(14)) && !"0".equals(data.get(14))) {
                    if (StringUtils.isBlank(data.get(13)) || "0".equals(data.get(13))) {
                        flages.add("21");
                    }
                    if (StringUtils.isBlank(data.get(14)) || "0".equals(data.get(14))) {
                        flages.add("22");
                    }
                } else {
                    flages.add("9");
                }
                if (StringUtils.isBlank(data.get(15)) || "0".equals(data.get(15))) {
                    flages.add("10");
                }
                if (StringUtils.isBlank(data.get(16)) || "0".equals(data.get(16))) {
                    flages.add("11");
                }
            }
            if (flages.contains("8") && flages.contains("9") && flages.contains("10") && flages.contains("11")) {
                flages.add("7");
            }
            item.setItemFlags(StringUtils.join(flages, ","));
            item.setGestinfoDayscope(data.get(17));
            item.setScheduleOrder(Integer.valueOf(StringUtils.isBlank(data.get(18)) ? "0" : data.get(18)));
            item.setBeginTime(data.get(19) != null ? Integer.valueOf(data.get(19)) : null);
            item.setBeginDays(data.get(20) != null ? Integer.valueOf(data.get(20)) : null);
            item.setExamRequire(data.get(21));
            List<String> days = CommonUtil.split2List(data.get(23));
            List<String> source = CommonUtil.split2List(data.get(24));
            List<String> text = CommonUtil.split2List(data.get(22));
            List<String> taboo = CommonUtil.split2List(data.get(25));
            List<String> smsDays = CommonUtil.split2List(data.get(26));
            List<String> smsTime = CommonUtil.split2List(data.get(27));
            List<String> smsApmStartTime = CommonUtil.split2List(data.get(28));
            List<String> smsApmEndTime = CommonUtil.split2List(data.get(29));
            List<String> smsContent = CommonUtil.split2List(data.get(30));
            String notice = "";
            if (days.size() <= 0 && source.size() <= 0) {
                if (text.size() > 0) {
                    notice = data.get(22);
                }
            } else {
                notice = "<notices>";
                for (int i = 0; i < source.size(); ++i) {
                    Map<String, String> map = new HashMap();
                    map.put("minDays", (days.size() > 1 ? days.get(i) : days.get(0)).split("~")[0]);
                    map.put("maxDays", (days.size() > 1 ? days.get(i) : days.get(0)).split("~")[1]);
                    map.put("patientSource", source.get(i));
                    map.put("text", text.size() > 1 ? text.get(i) : text.get(0));
                    map.put("taboo", taboo.size() > 1 ? taboo.get(i) : taboo.get(0));
                    map.put("smsDays", smsDays.size() > 1 ? smsDays.get(i) : smsDays.get(0));
                    map.put("smsTime", smsTime.size() > 1 ? smsTime.get(i) : smsTime.get(0));
                    map.put("smsApmStartTime", smsApmStartTime.size() > 1 ? smsApmStartTime.get(i) : smsApmStartTime.get(0));
                    map.put("smsApmEndTime", smsApmEndTime.size() > 1 ? smsApmEndTime.get(i) : smsApmEndTime.get(0));
                    map.put("smsContent", smsContent.size() > 1 ? smsContent.get(i) : smsContent.get(0));
                    notice = notice + JaxbXmlUtil.mapToXml(map);
                }
                notice = notice + "</notices>";
            }
            item.setNotice(notice);
            items.add(item);
        }
        dictExamItemService.insertBatch(items);
        return JsonResultUtil.success();
    }
}
